package com.itheima.admin.controller.v1;

import com.itheima.admin.service.ContentAuditService;
import com.itheima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 内容审核管理控制器
 * 
 * @author itheima
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/audit")
@Api(tags = "内容审核管理")
public class ContentAuditController {

    @Autowired
    private ContentAuditService contentAuditService;

    @GetMapping("/notes")
    @ApiOperation("获取待审核笔记列表")
    public ResponseResult getPendingNotes(@RequestParam(defaultValue = "1") Integer page,
                                         @RequestParam(defaultValue = "10") Integer size) {
        return contentAuditService.getPendingNotes(page, size);
    }

    @PutMapping("/notes/{id}")
    @ApiOperation("审核笔记")
    public ResponseResult auditNote(@PathVariable Long id, @RequestBody Map<String, Object> params) {
        return contentAuditService.auditNote(id, params);
    }

    @GetMapping("/reviews")
    @ApiOperation("获取待审核书评列表")
    public ResponseResult getPendingReviews(@RequestParam(defaultValue = "1") Integer page,
                                           @RequestParam(defaultValue = "10") Integer size) {
        return contentAuditService.getPendingReviews(page, size);
    }

    @PutMapping("/reviews/{id}")
    @ApiOperation("审核书评")
    public ResponseResult auditReview(@PathVariable Long id, @RequestBody Map<String, Object> params) {
        return contentAuditService.auditReview(id, params);
    }
}

